package com.mall.db.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mall.db.mapper.PmsProductFullReductionMapper;
import com.mall.pojo.PmsProductFullReduction;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PmsProductFullReductionApiAmpl implements PmsProductFullReductionApi {
    @Autowired
    private PmsProductFullReductionMapper pmsProductFullReductionMapper;

    //创建商品(八接口之一)
    @Override
    public void create(List<PmsProductFullReduction> productFullReductionList) {
        if (productFullReductionList != null) {
            for (PmsProductFullReduction pmsProductFullReduction : productFullReductionList) {
                pmsProductFullReductionMapper.insert(pmsProductFullReduction);
            }
        }

    }

    //更新商品 更新八张表之一
    @Override
    public void update(List<PmsProductFullReduction> productFullReductionList) {
        if (productFullReductionList != null) {
            for (PmsProductFullReduction pmsProductFullReduction : productFullReductionList) {
                pmsProductFullReductionMapper.updateById(pmsProductFullReduction);
            }
        }
    }

    @Override
    public List<PmsProductFullReduction> selectById(Integer id) {
        LambdaQueryWrapper<PmsProductFullReduction> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PmsProductFullReduction::getProductId, id);
        return pmsProductFullReductionMapper.selectList(wrapper);
    }
}
